<%- include("header",{type:''}) %>
<div class="container">
	<form style="width:100%" class="form create" method="post">
		<div>
			<label>標題：</label>
			<input placeholder="標題" type="text" name="title" value="<%- postsTitle %>">
		</div>
		<div>
			<label>内容：</label>
			<textarea name="content" id="" cols="42" rows="10"><%= postsContent %></textarea>
		</div>
		<div class="submit">修改</div>
	</form>
</div>
<script>
	$('.submit').click(function(){
		$.ajax({
            url: '',
            data: $('.form').serialize(),
            type: "POST",
            cache: false,
            dataType: 'json',
            success: function (msg) {
				if(msg.code != 200){
					fade('修改失敗')
				}else if (msg) {
               		fade('修改成功')
               		setTimeout(function (){
	               		window.location.href = "/posts"
               		},1000)
               	} 
            },
            error: function () {
                alert('服務器異常');
            }
        })		
	})
</script>
<% include footer %>